$(function(){
	if($('#time_range_select option').size() > 1){
		$('#schedule_box').modalpop({action:schedule})
		$('#schedule').click(function(){$('#schedule_box').modalpop('open')});
	}else{
		$('#schedule').click(function(){schedule_event(0)});
	}
	
	
	
});

function schedule(){
	$('#schedule_box').modalpop('close');
	schedule_event($('#time_range_select').val());
}
function schedule_event(index){
	var url = PublicUrls['SCHEDULE_EVENT'];
	$.ajax({
	    url: url,
	    data: {
	    	appointmentDate:$('[name="startDate_'+index+'"]').val(),
	    	appointmentHour:$('[name="startHour_'+index+'"]').val(),
	    	eventId:$('#eventId').val()
	    }	   
	});	    
}